<%@page import="entity.PageInfo"%>
<%@page import="entity.Teacher"%>
<%@page import="java.util.ArrayList"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" type="text/css" href="static/bootstrap-3.3.7-dist/css/bootstrap.css"/>
</head>
<body>
	<a href="<%=request.getContextPath()%>/teacher_insert.jsp">添加</a>
	<table  class="table table-striped table-bordered table-hover table-condensed">
		<tr>
			<th>ID</th>
			<th>名字</th>
			<th>年龄</th>
			<th>薪资</th>
			<th>删除</th>
			<th>修改</th>
		</tr>
		<%
			PageInfo pageInfo = (PageInfo)request.getAttribute("pageInfo");
			ArrayList<Teacher> list =  (ArrayList<Teacher>)pageInfo.getList();
			for (Teacher teacher : list) {
		%>
				<tr>
					<td><%=teacher.getId()%></td>
					<td><%=teacher.getName()%></td>
					<td><%=teacher.getAge()%></td>
					<td><%=teacher.getSalary()%></td>
					<td><a href="<%=request.getContextPath()%>/teacher?method=deleteById&id=<%=teacher.getId()%>">删除</a></td>
					<td><a href="<%=request.getContextPath()%>/teacher?method=selectById&id=<%=teacher.getId()%>">修改</a></td>
				</tr>
		<%
			}
		%>
		
	</table>
	
	<nav aria-label="Page navigation">
		  <ul class="pagination">
		  	<%
		  		if(pageInfo.getPageNo() == 1) {
		  	%>
		  			<li  class="disabled">
				      <a href="#" aria-label="Previous">
				        <span aria-hidden="true">&laquo;</span>
				      </a>
				    </li>
			<%
		  		} else {
		  	%>
		  			<li>
				      <a href="<%=request.getContextPath()%>/teacher?method=selectByPage&pageNo=<%=pageInfo.getPageNo()-1%>" aria-label="Previous">
				        <span aria-hidden="true">&laquo;</span>
				      </a>
				    </li>
			<%
		  		}
		  	%>
		   
		  
		  
		    <%
		    	for(int i = 1; i <= pageInfo.getTotalPage(); i++) {
		    		if (pageInfo.getPageNo() == i) {// 代表i当前的值就是当前页
		    %>
		    			<li class="disabled"><a href="#"><%=i%></a></li>
		    <%
		    		} else {
		    %>
		    			<li><a href="<%=request.getContextPath()%>/teacher?method=selectByPage&pageNo=<%=i%>"><%=i%></a></li>
		    <%
		    	    }
		    		
		    
		    	}
		    %>
		    
		   
		    <li>
		      <a href="<%=request.getContextPath()%>/teacher?method=selectByPage&pageNo=<%=pageInfo.getPageNo()+1%>" aria-label="Next">
		        <span aria-hidden="true">&raquo;</span>
		      </a>
		    </li>
		  </ul>
		</nav>
</body>
</html>